<?php 
/*
 * 回答控制器
 * */
class AnswerController extends AuthController{
	
	public function index(){
		//获得
		$ans=$_GET['ans'];
		switch ($ans) {
			case 1:
				//查询所有回答
				$sql="SELECT * FROM hd_answer ";
				$ansData=M()->query($sql);
				//p($ansData);
				$this->assign('ansData',$ansData);
				break;
			case 2:
				//没有采纳
				$sql="SELECT * FROM hd_answer WHERE accept=0";
				$ansData=M()->query($sql);
		//		p($ansData);
				$this->assign('ansData',$ansData);
				break;
			case 3:
				//等于一是采纳
				$sql="SELECT * FROM hd_answer WHERE accept=1";
				$ansData=M()->query($sql);
		//		p($ansData);
				$this->assign('ansData',$ansData);
				break;
		}
		
		$this->display();
	}
	
	 public function del(){
	 	//如果asid传参就走传入的值，没有就走默认
		$anid=isset($_GET['anid']) ? (int)$_GET['anid'] : 0;
		//p($cid);
		//执行删除，条件是判断回答的anid
		M()->exec("DELETE FROM hd_answer WHERE anid={$anid}");
		$this->error('删除成功');
	
		
		
	 }
	
	
	
	
}






 ?>